package cn.com.victorysoft.ylgl.service.commons.mybatis.paging.bean;

import cn.com.victorysoft.ylgl.service.commons.mybatis.mapping.Sort;

/***
 * @author gechaoqing
 */
public class PageRequest
        implements Pageable
{
    private int page;
    private int size;
    private Object parameters;
    private Sort sort;

    public PageRequest(int page, int size)
    {
        this(page, size, null);
    }

    public PageRequest(int page, int size, Object parameters)
    {
        this.page = (page < 1 ? 1 : page);
        this.size = (size < 1 ? 10 : size);
        this.parameters = parameters;
    }

    @Override
    public int getOffset()
    {
        return (this.page - 1) * this.size;
    }

    @Override
    public int getLimit()
    {
        return this.size;
    }

    @Override
    public Object getParameters()
    {
        return this.parameters;
    }

    @Override
    public Sort getSort()
    {
        return this.sort;
    }

    public void setSort(Sort sort)
    {
        this.sort = sort;
    }
}

